04. Flask-Migrate - Part 2

Flask_Migrate - Part 2

Creating the migrations directory structure using flask db init

Follow along! Interactive Workspace

Follow along the rest of the walk-throughs (below) to continue getting migrations set up on our Todo application.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: jupyter-lab
  • Opened files (when workspace is loaded): n/a

Walk-throughs

ND004 C01 L06 03.2 Flask-Migrate

Syncing models using flask db migrate

ND004 C01 L06 03.3 Flask-Migrate

To restart your postgres server

In case of an error with existing sessions or connections, you can stop your postgres server to close out existing connections, and then start it up again. Note that stopping a server does not affect the data inside it; they still persist.

To do so:

On MacOS if you installed postgres using Homebrew,

$ brew services start postgresql
$ brew services stop postgresql

Otherwise

You can call start and stop manually on your postgres server using pg_ctl , Postgres's application for starting, stopping, and controlling a Postgres server, included with every Postgres install:

To stop it, closing open connections, call

$ pg_ctl -D /usr/local/var/postgres stop

and to start it up again, call

$ pg_ctl -D /usr/local/var/postgres start